package map.android.baidu.carpool.reservation;

import java.util.ArrayList;

import android.content.Context;
import map.android.baidu.carpool.model.AirportTransCity;
import map.android.baidu.carpool.widget.wheel.AbstractWheelTextAdapter;

/**
 * Adapter class for old wheel adapter (deprecated WheelAdapter class).
 * 
 */
public class CitysWheelAdapter extends AbstractWheelTextAdapter {

	private ArrayList<AirportTransCity> mAllCityList;

	public void setData(ArrayList<AirportTransCity> mAllCityList) {
		this.mAllCityList = mAllCityList;
	}

	public CitysWheelAdapter(Context context) {
		super(context);
	}

	public AirportTransCity getItem(int index) {
		return mAllCityList == null ? null : mAllCityList.get(index);
	}

	@Override
	public CharSequence getItemText(int index) {
		AirportTransCity city = (AirportTransCity) getItem(index);
		String cityName = "";
		if ( city == null) {
			return "北京";
		}else{
			cityName = city.city_name;
		}
		return cityName;
	}

	@Override
	public int getItemsCount() {
		if (mAllCityList == null) {
			return 0;
		}
		return mAllCityList.size();
	}

}
